package com.personal_workspace_java.controller;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import com.personal_workspace_java.common.R;
import com.personal_workspace_java.common.PageResponse;
import com.personal_workspace_java.service.HotPostService;
import com.personal_workspace_java.model.dto.HotPostDto;
import com.personal_workspace_java.model.vo.HotPostVo;
/**
* @author 19324
*/
@Tag(name = "HotPost相关接口")
@RestController
@RequestMapping("/HotPost")
@Slf4j
public class HotPostController{

    @Resource
    private HotPostService hotPostService;

    //1.新增HotPost
    @Operation(summary = "新增HotPost")
    @PostMapping("/create")
    public R<Boolean> create(@RequestBody HotPostDto hotPostDto){
        hotPostService.create(hotPostDto);
        return R.success("新增成功");
    }

    //2.查询ByHotPostId
    @Operation(summary = "查询ByHotPostId")
    @PostMapping("/queryByHotPostId")
    public R<HotPostVo> queryByHotPostId(@RequestBody HotPostDto hotPostDto){
        HotPostVo hotPostVo=hotPostService.queryByHotPostId(hotPostDto);
        return R.success(hotPostVo,"查询成功");
    }

    //3.查询By其他字段
    @Operation(summary = "查询By其他字段")
    @PostMapping("/queryByOther")
    public R<HotPostVo> queryByOther(@RequestBody HotPostDto hotPostDto){
        HotPostVo hotPostVo=hotPostService.queryByOther(hotPostDto);
    return R.success(hotPostVo,"查询成功");
    }

    //4.查询所有
    @Operation(summary = "查询所有HotPost")
    @PostMapping("/queryAll")
    public R<List<HotPostVo>> queryAll(){
        List<HotPostVo> hotPostVoList=hotPostService.queryAll();
        return R.success(hotPostVoList,"查询成功");
    }

    //5.删除ByHotPostId
    @Operation(summary = "删除ByHotPostId")
    @PostMapping("/deleteByHotPostId")
    public R<Boolean> deleteByHotPostId(@RequestBody HotPostDto hotPostDto){
        hotPostService.deleteByHotPostId(hotPostDto);
        return R.success("删除成功");
    }

    //6.修改ByHotPostId
    @Operation(summary = "修改ByHotPostId")
    @PostMapping("/updateByHotPostId")
    public R<Boolean> updateByHotPostId(@RequestBody HotPostDto hotPostDto){
        hotPostService.updateByHotPostId(hotPostDto);
        return R.success("修改成功");
    }

    //7.分页查询HotPost
    @Operation(summary = "分页查询HotPost")
    @PostMapping("/queryHotPostByPage")
    public R<PageResponse<HotPostVo>> queryHotPostByPage(@RequestBody  HotPostDto hotPostDto){
        PageResponse<HotPostVo> pageResponse=hotPostService.queryHotPostByPage(hotPostDto);
            return R.success(pageResponse,"查询成功");
        }

    }